package com.example.Laboratory.Controller;

import com.example.Laboratory.Entity.Resource_sharing;
import com.example.Laboratory.Service.Resource_sharingService;
import com.example.Laboratory.Untils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Api(value = "Resource_sharing", description = "资源共享")
@RestController
@RequestMapping(value = "/Resource_sharing")
@CrossOrigin
public class Resource_sharingController {

    @Autowired
    Resource_sharingService resource_sharingService;

    @ApiOperation(value = "增加资源共享文件", notes = "增加资源共享文件")
    @RequestMapping(value = "/addResource_sharing", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object addResource_sharing (MultipartFile file, String resource_sharing_time) throws IOException {
        return ResultCode.SUCCESS.result(resource_sharingService.addResource_sharing(file, resource_sharing_time));
    }

    @ApiOperation(value = "删除资源共享文件", notes = "删除资源共享文件")
    @RequestMapping(value = "/deleteResource_sharing", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public Object deleteResource_sharing (int resource_sharing_id) throws IOException {
        return ResultCode.SUCCESS.result(resource_sharingService.deleteResource_sharing(resource_sharing_id));
    }

    @ApiOperation(value = "查找资源共享文件", notes = "查找资源共享文件")
    @RequestMapping(value = "/researchResource_sharing", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object researchResource_sharing ( ) throws IOException {
        return ResultCode.SUCCESS.result(resource_sharingService.researchResource_sharing());
    }

    @ApiOperation(value = "修改组织机构图片", notes = "修改组织机构图片")
    @RequestMapping(value = "/reviseResource_sharing", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object reviseOrganization(MultipartFile file, Resource_sharing r) throws IOException {
        return ResultCode.SUCCESS.result(resource_sharingService.reviseOrganization(file, r));
    }
}
